' nodeview.bmx

Strict

Import BRL.Stream
Import BRL.StandardIO

Import "tool.bmx"
Import "datanode.bmx"

Type TNodeView
	Field	root:TDataNode
	Field	treeview:TGadget
	Field	viewindex

	Method OnEvent()
		Local	n:TDataNode
		Local	g:TGadget
		g=TGadget(EventExtra())
		n=root.Find(g,viewindex)
		If Not n Return
		Select EventID()
			Case EVENT_GADGETSELECT
				n.invoke("SELECT")				
			Case EVENT_GADGETACTION
				n.invoke("ACTIVATE")				
			Case EVENT_GADGETMENU
				SelectTreeViewNode g
				n.invoke("MENU",Self)
			Case EVENT_GADGETOPEN
				n.open viewindex
			Case EVENT_GADGETCLOSE
				n.close viewindex
		End Select
	End Method
	
	Function CreateNodeView:TNodeView(group:TGadget,root:TDataNode)
		Local	nodeview:TNodeView
		nodeview=New TNodeView
		nodeview.root=root
		nodeview.treeview=CreateTreeView(0,0,ClientWidth(group),ClientHeight(group),group)
		Return nodeview
	End Function	
End Type
